﻿<div class="page-container" id="admui-pageContent">
    <div class="page animation-fade page-forms">
        <div class="page-header">
            <h1 class="page-title">房源列表</h1>
            <ol class="breadcrumb">
                <li class="breadcrumb-item">
                    <a class="icon wb-home" href="javascript:;">房源管理</a>
                </li>
                <li class="breadcrumb-item active">房源列表</li>
            </ol>
        </div>
        <div class="page-content">
            <div class="panel"> 
                <div class="panel-body">
                    <div class="example">
                        <div class="row">
                            <div class="col-sm-12">
                                <div class="row row-lg">
                                    <div class="col-sm-12 col-md-6">
                                        <div class="example-wrap margin-sm-0" id="div_yuanliaomingcheng">
                                            <h4 class="example-title">所属小区</h4>
                                            <div class="form-group">
                                                <select class="form-control" id="xiaoqu"></select>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-sm-12 col-md-2">
                                        <div class="example-wrap margin-sm-0" id="div_yuanliaomingcheng">
                                            <h4 class="example-title">楼号</h4>
                                            <div class="form-group">
                                                <select class="form-control" id="louhao"></select>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-sm-12 col-md-2">
                                        <div class="example-wrap margin-sm-0">
                                            <h4 class="example-title"></h4>
                                            <div class="form-group" style="margin-top: 28px;">
                                                <button type="button" class="btn btn-block btn-info" id="btn_tianjia" onclick="ChaKan();">查看</button>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-sm-12 col-md-2">
                                        <div class="example-wrap margin-sm-0">
                                            <h4 class="example-title"></h4>
                                            <div class="form-group" style="margin-top: 28px;">
                                                <button type="button" class="btn btn-block btn-info" id="btn_tianjia" onclick="FangYuanLouHaoXueGai();">修改</button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="page-content" style="width:100%;height:500px">
            <div class="panel">
                <div class="panel-body">
                    <div class="page-main">
                        <div class="page-content">
                            <div class="panel">
                                <table style="width: 100%; text-align: center;" border="1" cellspacing="0">

                                    <tbody>
                                        <tr>
                                            <td colspan="5" style="text-align:center;"><label id="xiaoqumingcheng" style="font-weight:bold;">请选择小区</label></td>
                                        </tr>
                                        <tr>
                                            <td rowspan="2">房屋状态</td>
                                            <td>总户数</td>
                                            <td style="background-color:red;color:black">已出售</td>
                                            <td style="background-color:gray;color:black">未出售</td>
                                            <td style="background-color:green;color:black">审核中</td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <label id="zoushu"></label>
                                            </td>
                                            <td>
                                                <label id="chushou"></label>
                                            </td>
                                            <td>
                                                <label id="weichushou"></label>
                                            </td>
                                            <td>
                                                <label id="shenhezhong"></label>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                                <div class="example-wrap m-lg-0">
                                    <div class="nav-tabs-horizontal" data-approve="nav-tabs">
                                        <div class="tab-content pt-20">
                                            <div class="tab-pane active" id="exampleTabsLineOne" role="tabpanel">
                                                <div style="width: auto;height:500px;white-space: nowrap; overflow-x: scroll;" id="div_DanYuan" >
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(document).ready(function () {
        var xiaoqu = getQuery("xiaoqu");
        var louhao = getQuery("louhao");
        var ceng = getQuery("ceng");

        if (xiaoqu != null && louhao != null)
        {
            ChaKan(xiaoqu, louhao);
            location.href = "#"+ ceng;
        }

        $("#SpanFangWu").click();
        XiaoQu();

        $("#xiaoqu").change(function () {
            louhaochaxu();
        });

    });

    function louhaochaxu() {

        var xiaoqu = jQuery("#xiaoqu").val();

        if (xiaoqu == "0") {
            $("#louhao").empty();
        } else {
            $("#louhao").empty();
            $.ajax({
                type: 'post',
                url: '../FangYuanXinXi/GetLouHao',
                async: false,
                dataType: 'json',
                data: { xiaoqu : xiaoqu },
                success: function (date) {
                    var ddl = $("#louhao");
                    ddl.append("<option value='0'>请选择</option>");
                    $(date).each(function (key) {
                        var opt = $("<option></option>").text(date[key].louHao).val(date[key].louHao);
                        ddl.append(opt);
                    })
                },
            })
        }
    }

    function XiaoQu() {

        $.ajax({
            type: 'post',
            url: '../FangYuanXinXi/GetXiaoQu',
            async: false,
            dataType: 'json',
            success: function (date) {
                var ddl = $("#xiaoqu");
                ddl.append("<option value='0'>请选择</option>");
                $(date).each(function (key) {
                    var opt = $("<option></option>").text(date[key].xiaoQuMingCheng).val(date[key].id);
                    ddl.append(opt);
                })
            },
        })

    }

    function ChaKan(xiaoqu, louhao) {
        if (xiaoqu != null && louhao != null) {

        } else {
            var xiaoqu = jQuery("#xiaoqu").val();
            var louhao = jQuery("#louhao").val();
        }

        if (xiaoqu == "0") {
            alert("请选择小区");
        } else if (louhao == "0") {
            alert("请选择楼号");
        } else {
            $.ajax({
                type: 'post',
                url: '../FangYuanXinXi/ChaKanFangWuShu',
                async: false,
                dataType: 'json',
                data: { xiaoqu: xiaoqu, louhao: louhao },
                success: function (date) {
                    $(date).each(function (key) {
                        $("#xiaoqumingcheng").text(date[key].xiaoqumingcheng);
                        $("#zoushu").text(date[key].zoushu);
                        $("#chushou").text(date[key].chushou);
                        $("#weichushou").text(date[key].weichushou);
                        $("#shenhezhong").text(date[key].shenhezhong);
                    })
                },
            });

            $.ajax({
                type: 'post',
                url: '../FangYuanXinXi/ChaKanXianShi',
                async: false,
                dataType: 'text',
                data: { xiaoqu: xiaoqu, louhao: louhao },
                success: function (date) {
                    $("#div_DanYuan").html(date);
                },
            });
        }
    }

    function FangYuanCengXueGai(ceng)
    {
        var xiaoqu = jQuery("#xiaoqu").val();
        var louhao = jQuery("#louhao").val();
        var cengshu = ceng;
        location.href = "../FangYuanXinXi/FangYuanCengUpdate?xiaoqu=" + xiaoqu + "&louhao=" + louhao +"&cengshu="+cengshu;
    }

    function FangYuanLouHaoXueGai()
    {
        var xiaoqu = jQuery("#xiaoqu").val();
        var louhao = jQuery("#louhao").val();
        location.href = "../FangYuanXinXi/FangYuanXinXiLouHaoUpdate?xiaoqu=" + xiaoqu + "&louhao=" + louhao;
    }

    function getQuery(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return decodeURI(r[2]); return null;
    }

</script>
